<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/inc/taglibs.jsp"%>
<script type="text/javascript">

	$('#consume_count').on('change',function(obj, value){
		var count = $(this).find('option:selected').attr('value');
		switch(count) {
			case '-1': {
				$('input[name$=gtConsumeMoney]').val('');
				$('input[name$=ltConsumeMoney]').val('');
				break;
			};
			case '1': {
				$('input[name$=gtConsumeMoney]').val(0);
				$('input[name$=ltConsumeMoney]').val(50);
				break;
			};
			case '2': {
				$('input[name$=gtConsumeMoney]').val(50);
				$('input[name$=ltConsumeMoney]').val(100);
				break;
			};
			case '3': {
				$('input[name$=gtConsumeMoney]').val(100);
				$('input[name$=ltConsumeMoney]').val('');
				break;
			};
		}
	});
</script>

<form id="pagerForm" method="post" action="${path }/admin/user/rechargeConsumeRecord">
	<input type="hidden" name="eqAccountName" value="${eqAccountName }"/>
	<input type="hidden" name="eqPhone" value="${eqPhone }" />
	<input type="hidden" name="eqIsPhoneValid" value="${eqIsPhoneValid }" />
	<input type="hidden" name="eqEmail" value="${eqEmail }" />
	<input type="hidden" name="eqIsEmailValid" value="${eqIsEmailValid }" />
	<input type="hidden" name="ltConsumeMoney" value="${ltConsumeMoney }" />
	<input type="hidden" name="gtConsumeMoney" value="${gtConsumeMoney }" />
	<input type="hidden" name="eqIsEmailValid" value="${eqIsEmailValid }" />
	<input type="hidden" name="gtConsumeTime" value="${gtConsumeTime }" />
	<input type="hidden" name="ltConsumeTime" value="${ltConsumeTime }" />
	<input type="hidden" name="consumnCount" value="${consumnCount }" />
	<input type="hidden" name="pageNum" value="${pageTurn.page }" />
	<input type="hidden" name="numPerPage" value="${pageTurn.pageSize }" />
	<input type="hidden" name="rel" value="${rel }" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="${path }/admin/user/rechargeConsumeRecord" method="post">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td>
                    <label>用户名：</label>
                    <input type="text" value="${eqAccountName}" name="eqAccountName" />
                </td>
				<td>
                    <label>手机号码：</label>
                    <input type="text" value="${eqPhone}" name="eqPhone" />
                </td>
				<td>
                    <label>邮箱：</label>
                    <input type="text" value="${eqEmail}" name="eqEmail" />
                </td>
				<td>
                    <label>订单号：</label>
                    <input type="text" value="${eqOrderId}" name="eqOrderId" />
                </td>
           </tr>
			<tr>
				<td>
					<label>消费金额：</label>
					<select name="consumnCount" id="consume_count">
						<option value="-1" ${consumnCount == -1 ? 'selected':'' }>不限</option>
						<option value="1" ${consumnCount == 1 ? 'selected':'' }>50元以下</option>
						<option value="2" ${consumnCount == 2 ? 'selected':'' }>50~100元</option>
						<option value="3" ${consumnCount == 3 ? 'selected':'' }>100元以上</option>
					</select>
					<input type="hidden" name="ltConsumeMoney" value="${ltConsumeMoney }" />
					<input type="hidden" name="gtConsumeMoney" value="${gtConsumeMoney }" />
				</td>
				<td colspan="2">
					<table><tr>
							<td>消费时间：</td>
							<td>
								<input type="text" value="${gtConsumeTime}" name="gtConsumeTime" class="date" dateFmt="yyyy-MM-dd HH:mm:ss" readonly="true" style="float:left;"/>
								<a class="inputDateButton" href="javascript:;" style="float:left;">选择</a>
							</td>
							<td>~</td>
							<td>
								<input type="text" value="${ltConsumeTime}" name="ltConsumeTime" class="date" dateFmt="yyyy-MM-dd HH:mm:ss" readonly="true" style="float:left;"/>
								<a class="inputDateButton" href="javascript:;" style="float:left;">选择</a>
							</td>
					</tr></table>
				</td>
				<td>
					<div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div>
				</td>
			</tr>
		</table>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
		<li class=""><a class="icon" href="javascript:;" id="exportBtn"><span>导出EXCEL</span></a></li>
		</ul>
	</div>
	<table class="table" width="100%" layoutH="140">
		<thead>
			<tr>
				<th>用户名</th>
				<th>手机号码</th>
				<th>邮箱</th>
				<th>消费金额(元)</th>
				<th>消费内容</th>
				<th>订单号</th>
				<th>消费时间</th>
			</tr>
		</thead>
		  <tbody> 
		  			<c:choose>
						<c:when test="${null==userRechargeConsumeRecordList||userRechargeConsumeRecordList.isEmpty()}">
							<tr class="tatr2">
								<td colspan="7" align="center">暂无数据</td>
							</tr>
						</c:when>
						<c:otherwise>
							<c:forEach items="${userRechargeConsumeRecordList}" var="consume">
								<tr>
									<td>${consume.accountName}</td>
									<td>${consume.isPhoneValid==1?consume.phone:''}</td>
									<td>${consume.isEmailValid==1?consume.email:''}</td>
									<td>${consume.consumeMoney}</td>
									<td>${consume.consumeContent}</td>
									<td>${consume.orderId}</td>
									<td><fmt:formatDate value="${consume.consumeTime }" pattern="yyyy-MM-dd HH:mm:ss" /></td>
								</tr>
							</c:forEach>
						</c:otherwise>
					</c:choose>
		</tbody>
	</table>

    <div style="clear:both"></div>
    <div class="panelBar">
        <%@ include file="/inc/admin_pagination.jsp" %>
    </div>
</div>
<script type="text/javascript">
    $("#exportBtn").click(function () {
    	var $form = $("#pagerForm");
        $.post("/admin/user/rechargeConsumeRecord/export.json", $form,
                function (data) {
                    if (data) {
                        if (data.fileName != null && data.fileName != '') {
                            window.location.href = data.fileName;
                        } else {
                            alert("导出文档失败！");
                        }
                    } else {
                        alert("导出文档失败！");
                    }
                }
        );
    });
</script>
